<html>
	<head>
		<title>JS时间对象以及数学常用函数</title>
		<meta http-equiv="Content-Type content=html/text" charset="utf-8">
		 <!-- <meta http-equiv="refresh" content="1"> -->

		<script>
			var today = new Date();

			document.write('获取当前年份：' + today.getFullYear() + "年<br />");
			document.write('获取当前月份：' + today.getMonth() + "月<br />");
			document.write('获取当前月共有' + today.getDate() + "天<br />");
			document.write('获取当前时间：' + today.getHours() + "时<br />");
			document.write('获取当前分数：' + today.getMinutes() + "分<br />");
			document.write('获取当前秒数：' + today.getSeconds() + "秒<br />");
			document.write('获取当前毫秒：' + today.getMilliseconds() + "毫秒<br />");
			document.write('今天是一周当中的第：' + today.getDay() + "天<br />");
			document.write('获取当前时间戳：' + today.getTime() + "（需要除1000）<br />");
			document.write(Date());

			var born = new Date(1992/6/3);

			var days = today.getTime() - born;
			document.write("<br />" + days/ 1000/3600/24);
			document.write("<hr />");

			/*数学对象*/
			//1.圆周率
			document.write("圆周率：" + Math.PI + "<br />");
			//绝对值
			document.write("绝对值：" + Math.abs(-5) + "<br />");
			//向上取整
			document.write("向上取整：" + Math.ceil(10.2) + "<br />");
			//向下取整
			document.write("向下取整：" + Math.floor(10.2) + "<br />");
			//四舍五入
			document.write("四舍五入：" + Math.round(12.6) + "<br />");
			//x的y次方
			document.write("x的y次方：" + Math.pow(2,3) + "<br />");
			//求平方根（开方）
			document.write("平方根：" + Math.sqrt(121) + "<br />");
			//0-1随机数
			document.write("随机数：" + Math.random() + "<br />");
			/*JS求某区间的随机数方法*/

			function getRandom(x1, x2) {
				var rand = Math.random() * (x2 - x1) + x1;
				rand = Math.floor(rand);
				return rand
			}
			var numb = getRandom(1, 10000);

			document.write(numb);
			alert("123");

		</script>
	</head>
	<body>
		
	</body>
</html>